﻿package view.tips
{
    import com.core.*;
    import com.core.destroy.*;
    import com.sh.game.util.*;
    import flash.display.*;
    import flash.text.*;
    import plugin.component.*;

    public class TaskcTips extends Sprite
    {
        private var taskbgClass:Class;
        private var _bg:Bitmap;
        private var _titleTxt:TextField;
        private var _descTxt:TextField;
        private var _nameTxt:TextField;
        private var _sxTxt:TextField;
        private var _jlTxt:TextField;
        private var cfgitem:Object;
        private var cfgchapter:Object;
        private var format1:TextFormat;
        private var format2:TextFormat;
        private var format3:TextFormat;
        private var _rewSprite:Sprite;

        public function TaskcTips()
        {
            this.taskbgClass = TaskcTips_taskbgClass;
            this.cfgitem = ConfigDictionary.data.item;
            this.cfgchapter = ConfigDictionary.data.chapter;
            this.format1 = new TextFormat("宋体", 16, null, true);
            this.format2 = new TextFormat("宋体", 12);
            this.format3 = new TextFormat("宋体", 12, null, true);
            this.format2.leading = 4;
            this.format3.leading = 4;
            this._bg = new Bitmap((new this.taskbgClass() as Bitmap).bitmapData);
            this.addChild(this._bg);
            this._titleTxt = new TextField();
            this._titleTxt.defaultTextFormat = this.format1;
            this._titleTxt.text = "第一章";
            this._titleTxt.textColor = MColor.New4;
            this._titleTxt.y = 50;
            this._titleTxt.width = this.width;
            this._titleTxt.autoSize = TextFieldAutoSize.CENTER;
            this.addChild(this._titleTxt);
            this._descTxt = new TextField();
            this._descTxt.defaultTextFormat = this.format2;
            this._descTxt.text = "发的是浪费框架是卡德加弗兰克";
            this._descTxt.textColor = MColor.New15;
            this._descTxt.x = 74;
            this._descTxt.y = 90;
            this._descTxt.width = 175;
            this._descTxt.height = 80;
            this._descTxt.wordWrap = true;
            this._descTxt.autoSize = TextFieldAutoSize.LEFT;
            this.addChild(this._descTxt);
            this._nameTxt = new TextField();
            this._nameTxt.defaultTextFormat = this.format2;
            this._nameTxt.text = "发的是浪费框架是卡德加弗兰克";
            this._nameTxt.textColor = MColor.New6;
            this._nameTxt.y = 180;
            this._nameTxt.width = this.width;
            this._nameTxt.autoSize = TextFieldAutoSize.CENTER;
            this.addChild(this._nameTxt);
            this._sxTxt = new TextField();
            this._sxTxt.defaultTextFormat = this.format3;
            this._sxTxt.text = "发的是浪费框架是卡德加弗兰克";
            this._sxTxt.textColor = MColor.New30;
            this._sxTxt.y = 200;
            this._sxTxt.x = 105;
            this._sxTxt.width = 150;
            this._sxTxt.wordWrap = true;
            this._sxTxt.autoSize = TextFieldAutoSize.LEFT;
            this.addChild(this._sxTxt);
            this._jlTxt = new TextField();
            this._jlTxt.defaultTextFormat = this.format2;
            this._jlTxt.text = "奖励预览";
            this._jlTxt.textColor = MColor.New6;
            this._jlTxt.y = 250;
            this._jlTxt.width = this.width;
            this._jlTxt.autoSize = TextFieldAutoSize.CENTER;
            this.addChild(this._jlTxt);
            this._rewSprite = new Sprite();
            this.addChild(this._rewSprite);
            this._rewSprite.x = 25;
            this._rewSprite.y = 280;
            return;
        }// end function

        public function set data(param1:int) : void
        {
            var _loc_4:Object = null;
            var _loc_5:FlashItem = null;
            var _loc_2:* = ModelProxy.getValue("data", "taskchapterid");
            if (_loc_2 == 0)
            {
                return;
            }
            var _loc_3:* = UserData.getUserData("career");
            var _loc_6:* = UserData.getUserData("sex");
            var _loc_7:* = this.cfgchapter[_loc_2];
            var _loc_8:* = this.cfgchapter[_loc_2].rewards;
            this._descTxt.htmlText = _loc_7.tips;
            this._nameTxt.text = "完成本章的“" + _loc_7.name + "”增加属性:";
            this._titleTxt.text = "主线任务《" + _loc_7.tname + "》";
            var _loc_9:* = int(_loc_7.shuxing);
            switch(_loc_9)
            {
                case 1:
                {
                    if (_loc_3 == 1)
                    {
                        this._sxTxt.text = "物理攻击：" + _loc_7.count + "-" + _loc_7.count;
                    }
                    else if (_loc_3 == 2)
                    {
                        this._sxTxt.text = "魔法攻击：" + _loc_7.count + "-" + _loc_7.count;
                    }
                    else
                    {
                        this._sxTxt.text = "道士攻击：" + _loc_7.count + "-" + _loc_7.count;
                    }
                    break;
                }
                case 2:
                {
                    this._sxTxt.htmlText = "物理防御： " + _loc_7.count + "-" + _loc_7.count + "\n" + "魔法防御： " + _loc_7.count + "-" + _loc_7.count;
                    break;
                }
                case 3:
                {
                    this._sxTxt.text = "生命上限： " + _loc_7.count;
                    break;
                }
                case 4:
                {
                    this._sxTxt.text = "魔法上限： " + _loc_7.count;
                    break;
                }
                default:
                {
                    break;
                    break;
                }
            }
            var _loc_10:int = 0;
            DestroyUtil.removeChildren(this._rewSprite);
            var _loc_11:int = 0;
            while (_loc_11 < _loc_8.length)
            {
                
                if (_loc_8[_loc_11] == null)
                {
                }
                else if (_loc_8[_loc_11].career == 0)
                {
                    if (_loc_8[_loc_11].sex == 2)
                    {
                        _loc_4 = this.cfgitem[_loc_8[_loc_11].itemid];
                        _loc_5 = new FlashItem(_loc_4, 0.6, false, false, null, true, true);
                        _loc_5.x = 50 + _loc_10 * (46 + 3);
                        this._rewSprite.addChild(_loc_5);
                        _loc_10++;
                    }
                    else if (_loc_8[_loc_11].sex == _loc_6)
                    {
                        _loc_4 = this.cfgitem[_loc_8[_loc_11].itemid];
                        _loc_5 = new FlashItem(_loc_4, 0.6, false, false, null, true, true);
                        _loc_5.x = 50 + _loc_10 * (46 + 3);
                        this._rewSprite.addChild(_loc_5);
                        _loc_10++;
                    }
                }
                else if (_loc_8[_loc_11].career == _loc_3)
                {
                    if (_loc_8[_loc_11].sex == 2)
                    {
                        _loc_4 = this.cfgitem[_loc_8[_loc_11].itemid];
                        _loc_5 = new FlashItem(_loc_4, 0.6, false, false, null, true, true);
                        _loc_5.x = 50 + _loc_10 * (46 + 3);
                        this._rewSprite.addChild(_loc_5);
                        _loc_10++;
                    }
                    else if (_loc_8[_loc_11].sex == _loc_6)
                    {
                        _loc_4 = this.cfgitem[_loc_8[_loc_11].itemid];
                        _loc_5 = new FlashItem(_loc_4, 0.6, false, false, null, true, true);
                        _loc_5.x = 50 + _loc_10 * (46 + 3);
                        this._rewSprite.addChild(_loc_5);
                        _loc_10++;
                    }
                }
                _loc_11++;
            }
            return;
        }// end function

    }
}
